package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

public class CalculateActivity extends AppCompatActivity {
    private static final String TAG = "CalculateActivity";
    private float Rate;
    TextView result;
    String Ckind;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_calculate);
        result = findViewById(R.id.cur);

        Intent intent = getIntent();
         Ckind = intent.getStringExtra("title");
         Rate = intent.getFloatExtra("detail", 100f);
         result.setText(Ckind);
    }
    public void click(View btn) {
        EditText input = findViewById(R.id.rmb);
        String s = input.getText().toString();
        if (s.length() == 0) {
            Toast.makeText(this, "请输入数据", Toast.LENGTH_SHORT).show();
            return;
        }
        float inp = Float.parseFloat(s);
        float r = 0.0f;
        r = inp * Rate;
        //TextView result=findViewById(R.id.result);

        result.setText(s+"元人民币可兑换：  "+String.valueOf(r)+Ckind);

    }
}